package PTA.ch06;

//尽量使用offer()方法添加元素，使用poll()方法移除元素。dd()和remove()方法在失败的时候会抛出异常。
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class ex06 {

    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int n = cin.nextInt();
        Queue<Integer> a= new LinkedList<>();;
        Queue<Integer> b= new LinkedList<>();;
        for(int i=0;i<n;i++)
        {
            int num = cin.nextInt();
            if(num%2==1) {
                a.add(num);   //奇数到 a 窗口
            } else if(num%2==0) {
                b.add(num);//偶数 到 b窗口
            }
        }
        int flag=0;
        while(!a.isEmpty() || !b.isEmpty())
        {
            if(!a.isEmpty()) {
                if(flag==0)
                {
                    System.out.print(a.peek());
                    a.remove();
                    flag=1;
                }
                else {
                    System.out.print(" "+a.peek());
                    a.remove();
                }
            }
            if(!a.isEmpty()) {
                System.out.print(" "+a.peek());
                a.remove();
            }
            if(!b.isEmpty()) {
                if(flag==0)
                {
                    System.out.print(b.peek());
                    b.remove();
                    flag=1;
                }
                else {
                    System.out.print(" "+b.peek());
                    b.remove();
                }
            }
        }
    }
}

